define(function (require,exports,module) {
    var myPub = require('./public');

    var oWindow = $(window);
    var oContain = $('.js_contain');
    var oSearchVoiceCon = $('.js_searchVoiceCon');

    var oFooter = $('.js_searchFooter');    //底部
    var oFootLe = $('.js_searchVoiceFootLe');   //底部左边切换语音还是输入法
    var oFootRi = $('.js_searchVoiceFootRi');   //底部右边打开还是不打开下面的详情
    var oFootCen = $('.js_searchVoiceFootCen');   //底部中部部分
    var oFootMic = $('.js_searchVoiceRec');       //底部中间语音图标部分
    var oFootInput = $('.js_wannaSearch');        //底部输入法对象
    var oClearSearch = $('.js_clearSearchInput');  //底部输入法清除按钮
    var oDialogueBox = $('.js_searchVoiceDialogue');  //装对话的盒子
    var oSearchVoiceTop = $('.js_searchVoiceTop');
    var oSearchMic = $('.js_searchVoiceRecMic');
    var oSearchWave = $('.js_searchWave');
    var oLoading = $('.js_searchLoadPage');
    var oVoiceEsoterica = $('.js_voiceEsoterica');   //语音秘籍
    var oFirstAutoPlay = $('.js_autoPlay');   //第一条播放的语音
    var oCheckService = $('.js_checkService');


    var state = 0;  //记录长按状态
    var lastTime = null;     //记录长按开始时间
    var timeout = null,countDownTime = null;      //记录长按倒计时
    var min_x = 0 , max_x = 0;         //记录语音长按开始位置
    var min_y = 0 , max_y = 0;         //记录语音长按开始位置
    var lastAudioEnd = false;         //记录上条语音放完了没有

    var oCheckServiceJRoll = new myPub.ScrollBar();

    var loadEnd = true;   //加载开关

    var touchStart = false;   //记录是否开始长按

    //请求接口
    var baseUrl = "/robot/robotDetail";

    var start_x = 0,  start_y = 0, initLeft = oVoiceEsoterica.offset().left, initWidth = oVoiceEsoterica.outerWidth(true), initTop = oVoiceEsoterica.offset().top , changeTop = 0; //记录语音秘籍的开始位置
// console.log('kkk',initLeft,initWidth)

    //默认先播放第条语音
    // oFirstAutoPlay.on('ended',function (e) {
    //     var index = $('.js_autoPlay').index($(this)) + 1;
    //     if($('.js_autoPlay').eq(index).length > 0){
    //         $('.js_autoPlay').eq(index).get(0).play();
    //     }else {
    //         lastAudioEnd = true;
    //         return;
    //     }
    //
    // });

    //底部左边切换点击方法
    oFootLe.on('click',function (e) {
       var $this = $(this);
       // 如果是显示输入文字，底部整个背景要变成白的
       if(!$this.hasClass('active')){
           oFooter.addClass('active');
           oFootCen.addClass('active');
       //    输入栏聚焦
           oFootInput.focus();
       }else {
           oFooter.removeClass('active addHeight');
           oFootRi.removeClass('active');
           oFootCen.removeClass('active');
       }
       $this.toggleClass('active');
    });

    //底部右边打开底部更多
    oFootRi.on('click',function (e) {
       var $this = $(this);
       if($this.hasClass('sendShow')){
           if(searchObj.userInputVal.length > 0){
               oDialogueBox.append(searchHtml.userQuestionH(searchObj.userInputVal));

               //加一个加载缓冲的信息
               oDialogueBox.append(searchHtml.platformLoadingHtml());
               searchObj.scrollToTop();

               searchObj.getAnswerData(searchObj.userInputVal);
               oFootInput.val('');
               oClearSearch.hide();
               var scrollTop = $('.js_searchVoiceTop').outerHeight(true)-oSearchVoiceCon.height();
               oSearchVoiceCon.stop().animate({scrollTop: scrollTop});

           }
       //    发送后不在显示发送
           $this.removeClass('sendShow');
       }
       else {
           //如果显示底下更多，中间输入法的也要跟着切换
           if($this.hasClass('active')){
               oFooter.removeClass('addHeight active');
               oFootLe.removeClass('active');
               oFootCen.removeClass('active');
               // 还原padding
               oSearchVoiceCon.css({'padding-bottom': '6.49rem'});
               var scrollTop = $('.js_searchVoiceTop').outerHeight(true)-oSearchVoiceCon.height();
               oSearchVoiceCon.stop().animate({scrollTop: scrollTop});
           }else {
               oFooter.addClass('addHeight active');
               oFootLe.addClass('active');
               oFootCen.addClass('active');
               //语音秘籍位置如果被遮住就要提高一下
               if($(window).height()-oVoiceEsoterica.offset().top < oFooter.height()) {
                   oVoiceEsoterica.css({bottom: oFooter.height() + 10});
               }
               var extraH = $(window).width()*70/750;
               oSearchVoiceCon.css({'padding-bottom': oFooter.height() + extraH});
               var scrollTop = $('.js_searchVoiceTop').outerHeight(true)-oSearchVoiceCon.height();
               oSearchVoiceCon.stop().animate({scrollTop: scrollTop});
           }
           $this.toggleClass('active');
       }

    });

    //输入法输入
    oFootInput.on('input',function (e) {
        var value = e.target.value;
        searchObj.userInputVal = value;
        if(value.length>0){
            oClearSearch.show();
            oFootRi.addClass('sendShow');
        }else {
            oClearSearch.hide();
            oFootRi.removeClass('sendShow');
        }
    });

    //输入内容按回车键或发送键事件
    oFootInput.on('keypress',function (e) {
        var keycode = e.keyCode;
        var value = e.target.value;
        if(keycode == '13'){
            if(value.length > 0){
                oDialogueBox.append(searchHtml.userQuestionH(value));
                oFootInput.val('');
                oClearSearch.hide();
                oFootRi.removeClass('sendShow');
                searchObj.scrollToTop();

                //加一个加载缓冲的信息
                oDialogueBox.append(searchHtml.platformLoadingHtml());
                searchObj.scrollToTop();

                searchObj.getAnswerData(value)
            }
        }

    });

    //输入获取焦点
    oFootInput.on('focus',function (e) {
        oFooter.removeClass('addHeight');
        oFootRi.removeClass('active');
        // 还原padding
        oSearchVoiceCon.css({'padding-bottom': '6.49rem'});
        var scrollTop = $('.js_searchVoiceTop').outerHeight(true)-oSearchVoiceCon.height();
        oSearchVoiceCon.stop().animate({scrollTop: scrollTop});
        var timer = null;
        myPub.setFocusBodyScrollTop(timer);
    });

    //输入失去焦点
    // oFootInput.on('blur',function (e) {
    //     $('body')[0].scrollTop = 0;
    // });


    //输入内容清除
    oClearSearch.on('click',function (e) {
       oFootInput.val('');
       oFootRi.removeClass('sendShow');
       $(this).hide();
    });


    //按住语音开始事件
    oFootMic.on('touchstart',function (e) {
        e.preventDefault();

        if(loadEnd){
            loadEnd =false;
            touchStart = true;
            //按语音，停掉所有播放着的语音
            searchObj.audioPlay(true);

            var $this = $(this);
            lastTime = new Date().getTime();
            oLoading.show();
            clearTimeout(timeout);
            $this.addClass('active');
            max_x = $this.offset().left + $this.height() + 20;
            max_y = $this.offset().top + $this.height() + 20;
            min_x = $this.offset().left  - 20;
            min_y = $this.offset().top  - 20;
            wx.startRecord();
            timeout = setTimeout(function () {
                state = 1;
                clearTimeout(timeout);
                searchObj.tenSecondStop();

            },800);

            // if(state == 1){
            //     //如果10秒后用记还没录完就自动停止
            //     clearTimeout(countDownTime);
            //     countDownTime = setTimeout(function () {
            //         alert('000000');
            //         searchObj.stopRecordFn();
            //         oLoading.hide();
            //         $this.removeClass('active');
            //     },10500);
            // }



        }

    });

    //按住语音开始移动事件
    oFootMic.on('touchmove',function (e) {
        e.preventDefault();
        var $this = $(this);
        var endX = e.originalEvent.changedTouches[0].pageX;
        var endY = e.originalEvent.changedTouches[0].pageY;
        // var distanceX = start_x - endX;
        // var distanceY = start_y - endY;
        // var micH = 10;
        if(touchStart){
            // state = 0;
            if( endX < min_x || endX > max_x){
                oLoading.hide();
                $this.removeClass('active');
                searchObj.stopRecordFn();
                touchStart = false;
            }
            if( endY < min_y || endY > max_y){
                oLoading.hide();
                $this.removeClass('active');
                searchObj.stopRecordFn();
                touchStart = false;
            }
        }

    });

    //按住语音结束事件
    oFootMic.on('touchend',function (e) {
        e.preventDefault();

        var $this = $(this);
        touchStart = false;
        oLoading.hide();
        $this.removeClass('active');
        if( state == 1){
            // touchStart = false;

            // oLoading.hide();
            //
            // $this.removeClass('active');
            // state = 0;
            searchObj.stopRecordFn();

        }else {
            state = 0;
            clearTimeout(timeout);
            searchObj.stopRecordFn(true);
        }

    });

    //语音秘籍按住开始事件
    oVoiceEsoterica.on('touchstart',function (e) {
        // e.preventDefault();
        var $this = $(this);
        start_x = e.originalEvent.changedTouches[0].pageX;
        start_y = e.originalEvent.changedTouches[0].pageY;
        changeTop = oVoiceEsoterica.offset().top;
    });

    //语音秘籍按住移动事件
    oVoiceEsoterica.on('touchmove',function (e) {
        // e.preventDefault();
        var $this = $(this);
        var end_x = e.originalEvent.changedTouches[0].pageX;
        var end_y = e.originalEvent.changedTouches[0].pageY;
        var distanceX = start_x > end_x ? start_x - end_x : 0;
        var distanceY = end_y - start_y;
        var maxMoveX = initLeft - $(window).width() + initWidth;
        var oHeadH = $('.js_headerBox').height() + (start_y - changeTop);
        if(distanceX > 0) {
            if(distanceX <= maxMoveX){
                oVoiceEsoterica.css({right : -(maxMoveX - distanceX)});
            }else {
                oVoiceEsoterica.css({right : 0});
            }
        }
        if(end_y > oHeadH && end_y < (initTop + oVoiceEsoterica.outerHeight(true))){
            var moveBot = ($(window).height() - (changeTop + oVoiceEsoterica.outerHeight(true))) - distanceY;
            oVoiceEsoterica.css({bottom: moveBot})
        }


    });

    //语音秘籍按住结束事件
    oVoiceEsoterica.on('touchend',function (e) {
        // e.preventDefault();
        var $this = $(this);
        var maxMoveX = initLeft - $(window).width() + initWidth;
        $this.css({right : -maxMoveX});

    });






    module.exports={
        init:function (data) {
            // searchObj.SetAdsLiScroll($('.js_HScroll'),0);
            searchObj.initEvent();
            searchObj.getPageData();
            searchObj.initFn();
            // searchObj.audioPlay()
        }
    };


    var searchObj={
        oSlideAdsScroll: [],
        userInputVal:'',    //保存用户输入的内容
        newAudio: '',
        localId: 0,    //语音的id
        initFn:function () {
            if(oCheckServiceJRoll.obj === undefined ){
                oCheckServiceJRoll.AddScroll(oCheckService[0],{
                    scrollY: false,
                    scrollX: true
                })
            } else {
                oCheckServiceJRoll.ReScroll();
            }
        },
        // 设置滚动广告
        SetAdsLiScroll: function (obj,swiperIndex) {
            var oHScrollBox = obj.find('.js_HScroll');
            var _this = this;
            var isSwiper = null;


            if(_this.oSlideAdsScroll[0] == undefined) {
                _this.oSlideAdsScroll[0] = [];
                _this.oSlideAdsScroll[0].swiper = [];
            }

            if(_this.oSlideAdsScroll[0].swiper[swiperIndex] == undefined) {
                AddSwiper();
            }
            else {
                _this.oSlideAdsScroll[0].swiper[swiperIndex].destroy();
                _this.oSlideAdsScroll[0].swiper[swiperIndex] = null;
                AddSwiper();
            }

            function AddSwiper() {
                isSwiper = oHScrollBox.swiper({
                    freeMode: true,
                    freeModeMomentumRatio: 0.5,
                    lazyLoading: true,
                    watchSlidesProgress: true,
                    watchSlidesVisibility: true,
                    slideClass: 'slide-HScroll',
                    slidesPerView: 'auto',
                    observer: true,
                    observeParents: true,

                    onTouchEnd: function (swiper) {

                    }


                });
                _this.oSlideAdsScroll[0].swiper[swiperIndex] = isSwiper;
            }


        },
        scrollToTop: function () {
            var scrollTop = $('.js_searchVoiceTop').outerHeight(true)-oSearchVoiceCon.height();
            oSearchVoiceCon.stop().animate({scrollTop: scrollTop});
        },
        getAnswerData: function (value,type) {

            G_JSON_POST(baseUrl,{keyWord: value, start: 0, limit: 10},function (res) {
                console.log('---',res);
                var res = res;
                //如果是从语音秘籍页面进来，模拟用发送信息
                if(type == 1){
                    oDialogueBox.append(searchHtml.userQuestionH(value));
                }
                if(res.status == 'success'){
                    res.data = res.data == null || res.data == undefined ? [] : res.data;

                    if(res.data.length > 0){
                        //如果是查物流的，拼接的html不一样
                        //code -- 1代表物流，2代表购物车，3代表随便逛逛，4代表商品搜索，5代表优惠券
                        if(res.code == 1){

                            //如果是从语音秘籍页面进来，模拟用发送信息
                            if(type == 1){
                                oDialogueBox.append(searchHtml.userQuestionH(value));
                            }

                            oDialogueBox.append(searchHtml.oneLogisMesHtml(res.data,res.keyWordsCode));
                            searchObj.scrollToTop();
                            //如有新的消息要播报，就先停了之前的语音再播放
                            searchObj.audioPlay();
                            //加载开关关闭
                            loadEnd = true;
                        }
                        else{
                            if(res.code == 2){
                                var dataObj = { msg : res.msg};
                                var audioName = 'audio_cart';

                                oDialogueBox.append(searchHtml.platformAnswerHtml(res.msg,audioName));

                                //如有新的消息要播报，就先停了之前的语音再播放
                                searchObj.audioPlay();
                                //需要滑动到最底部，让用户看到最新的消息
                                searchObj.scrollToTop();
                                //加载开关关闭
                                loadEnd = true;
                            }
                            else if(res.code == 5){
                                var dataObj = {msg:'主人，点击查看您的优惠券'};
                                var audioName = 'audio_coupon';
                                oDialogueBox.append(searchHtml.platformAnswerHtml(dataObj,audioName));

                                //如有新的消息要播报，就先停了之前的语音再播放
                                searchObj.audioPlay();

                                //加载商品列表
                                oDialogueBox.append(searchHtml.couponListHtml(res,keyWord));

                                var oGoodsSwiper = oDialogueBox.find('.js_HScroll');
                                oGoodsSwiper.each(function (e) {
                                    //需要设置swiper
                                    searchObj.SetAdsLiScroll(oDialogueBox,e);
                                });

                                //需要滑动到最底部，让用户看到最新的消息
                                searchObj.scrollToTop();
                                //加载开关关闭
                                loadEnd = true;
                            }
                            else {


                                var resKey = [];
                                //当用户点随便逛逛时，keyword没有返回
                                if(res.code == 3){
                                    var keyWord = '推荐商品';
                                }else if(res.code == 4) {
                                    var keyWord = '';

                                    if(res.keyWord){
                                        resKey = res.keyWord.split(';');
                                        for(var i = 0; i < resKey.length; i++){
                                            if(!resKey[i] && i == resKey.length-1){
                                                resKey.splice(i,1);
                                            }
                                        }
                                        keyWord = resKey.join('、');
                                    }
                                    else {
                                        keyWord = '推荐商品'
                                    }
                                }

                                var dataObj = {msg:'来看看我为主人挑选的'+ keyWord};
                                var audioName = '';
                                if(keyWord.indexOf('苹果') > -1 && resKey.length == 1){
                                    audioName = 'audio_apple';
                                }
                                else if(keyWord.indexOf('车厘子') > -1 && resKey.length == 1){
                                    audioName = 'audio_cherry';
                                }
                                else if(keyWord.indexOf('推荐商品') > -1){
                                    audioName = 'audio_recommend';
                                }
                                else {
                                    audioName = 'audio_selGoods';
                                }
                                oDialogueBox.append(searchHtml.platformAnswerHtml(dataObj,audioName));

                                //如有新的消息要播报，就先停了之前的语音再播放
                                searchObj.audioPlay();

                                //加载商品列表
                                oDialogueBox.append(searchHtml.goodsListBoxHtml(res,keyWord));

                                var oGoodsSwiper = oDialogueBox.find('.js_HScroll');
                                oGoodsSwiper.each(function (e) {
                                    //需要设置swiper
                                    searchObj.SetAdsLiScroll(oDialogueBox,e);
                                });

                                //需要滑动到最底部，让用户看到最新的消息
                                searchObj.scrollToTop();
                                //加载开关关闭
                                loadEnd = true;
                            }

                        }
                    }
                    else {
                        //如果是购物车的就直接显示返回的数据
                        if(res.code == 2){
                            var dataObj = { msg : res.msg};
                            var audioName = 'audio_cart';
                        }
                        else if(res.code == 1){
                            var dataObj = res.keyWordsCode ==1 ? {msg: '主人，找不到您的订单'} :  {msg: '主人，找不到您有待收货的订单'};
                            var audioName = res.keyWordsCode ==1 ? 'audio_notAllOrder' : 'audio_notWaitGet';
                        }
                        else if(res.code == 5){
                            var dataObj = { msg: '主人，您无可用的优惠券'};
                            var audioName = 'audio_notCoupon';
                        }
                        else {
                            var dataObj = {msg:'出了点小差错，等等再聊吧~'};
                            var audioName = 'audio_error';
                        }
                        //如果请求回来成功，但没数据，要显示的提示
                        oDialogueBox.append(searchHtml.platformAnswerHtml(dataObj,audioName));
                        //如有新的消息要播报，就先停了之前的语音再播放
                        searchObj.audioPlay();
                        //需要滑动到最底部，让用户看到最新的消息
                        searchObj.scrollToTop();
                        //加载开关关闭
                        loadEnd = true;
                    }
                }
                else {
                    //如果请求不成功，要显示提示
                    oDialogueBox.append(searchHtml.platformAnswerHtml(res,'audio_error'));
                    //如有新的消息要播报，就先停了之前的语音再播放
                    searchObj.audioPlay();
                    //需要滑动到最底部，让用户看到最新的消息
                    searchObj.scrollToTop();
                    //加载开关关闭
                    loadEnd = true;
                }
            })
        },
        initEvent: function () {
            oContain.on('click',function (e) {
                var _target = e.target;
                var $target;
                //判断是否跳我的订单
                _target.nodeName.toLowerCase() == 'p' ? $target = $(_target) : $target = $(_target).parents('.js_orderDe');
                // console.log('--',$target);
                if($target.hasClass('js_orderDe')){
                    var loca = $target.attr('jumpName');
                    localStorage.setItem("orderNav_index", loca);
                    window.location.href =  '/shop/pay/order_list';
                }

            //    判断是否是查物流或查随便逛逛
                _target.nodeName.toLowerCase() == 'div' ? $target = $(_target) : $target = $(_target).parents('.js_checkMenu');
                if($target.hasClass('js_checkMenu')){
                    if(loadEnd){
                        loadEnd = false;
                        var value = $target.attr('checkValue');
                        //加一个加载缓冲的信息
                        oDialogueBox.append(searchHtml.platformLoadingHtml());
                        searchObj.scrollToTop();

                        searchObj.getAnswerData(value);
                    }else {
                        return;
                    }

                }
            })
        },
        audioPlay:function (allEnd) {
            //如有新的消息要播报，就先停了之前的语音再播放
            oContain.find('.js_autoPlay').each(function (e) {
                $('.js_autoPlay').eq(e).get(0).pause();
            });
            if(!allEnd){
                if(typeof WeixinJSBridge == 'object' && typeof WeixinJSBridge.invoke == 'function'){
                    WeixinJSBridge.invoke('getNetworkType',{},function (res) {
                        console.log('ohmyGOdfail');
                        oContain.find('.js_autoPlay:last').get(0).play();
                    })
                }

            }


        },
        stopRecordFn: function (isTrans) {
            loadEnd = false;
            wx.stopRecord({
                success: function (res) {
                    searchObj.localId = res.localId;
                    if(!isTrans){
                        //加一个加载缓冲的信息
                        oDialogueBox.append(searchHtml.userLoadingHtml());
                        //需要滑动到最底部，让用户看到最新的消息
                        searchObj.scrollToTop();
                        wx.translateVoice({
                            localId: res.localId, // 需要识别的音频的本地Id，由录音相关接口获得
                            isShowProgressTips: 0, // 默认为1，显示进度提示
                            success: function (res) {
                                // alert('===='+typeof(res.translateResult),res.translateResult); // 语音识别的结果
                                var result = res.translateResult != 'undefined' && res.translateResult != 'null' && res.translateResult && res.translateResult != undefined ? res.translateResult : '';
                                if(result){
                                    oDialogueBox.append(searchHtml.userQuestionH(result));
                                    //加一个加载缓冲的信息
                                    oDialogueBox.append(searchHtml.platformLoadingHtml());
                                    searchObj.scrollToTop();

                                    searchObj.getAnswerData(result);
                                }
                                else {
                                    var dataObj = { msg : '小妹没听清楚主人说什么哟,麻烦再说一次'};
                                    var audioName = 'audio_sayAgain';
                                    oDialogueBox.append(searchHtml.platformAnswerHtml(dataObj,audioName));
                                    //如有新的消息要播报，就先停了之前的语音再播放
                                    searchObj.audioPlay();
                                    //需要滑动到最底部，让用户看到最新的消息
                                    searchObj.scrollToTop();
                                    loadEnd = true;
                                }


                            },
                            fail: function (err) {
                                // alert('----',err);
                                var dataObj = { msg : '小妹没听清楚主人说什么哟,麻烦再说一次'};
                                var audioName = 'audio_sayAgain';
                                oDialogueBox.append(searchHtml.platformAnswerHtml(dataObj,audioName));
                                //如有新的消息要播报，就先停了之前的语音再播放
                                searchObj.audioPlay();
                                //需要滑动到最底部，让用户看到最新的消息
                                searchObj.scrollToTop();
                                loadEnd = true;
                            }
                        });
                    }
                    else {
                        loadEnd = true;
                    }

                },
                fail: function (err) {
                    loadEnd = true;
                }
            });
        },
        getPageData: function () {
            var _this = this;
            //  获取页面路径数据
            // console.log(window.location.search);
            var searchData =  window.location.search;

            if(searchData){
                var searchDataArr = searchData.substring(1).split('&');
                var newSearchDataArr = [];
                for(var i = 0; i < searchDataArr.length; i++){
                    newSearchDataArr.push({});
                    var item = searchDataArr[i].split('=');
                    // console.log('--',item);
                    newSearchDataArr[i][item[0]] = decodeURI(item[1]);

                }
                // console.log(newSearchDataArr)
                if(newSearchDataArr[0].keyWord){
                    _this.getAnswerData(newSearchDataArr[0].keyWord,1)
                }
            }

        },
        tenSecondStop: function () {
            //如果10秒后用记还没录完就自动停止
            clearTimeout(countDownTime);
            countDownTime = setTimeout(function () {
                if(!loadEnd){
                    searchObj.stopRecordFn();
                }
                oLoading.hide();
                oFootMic.removeClass('active');
            },5500);
        }
    };

    var searchHtml = {
        userQuestionH: function (data) {

            // 删除加载的数据
            oContain.find('.js_userLoadingGif').remove();

            var shtml='';
            shtml='<section class="userSendInfo marTop_70">' +
                  '   <div class="userSendInfoCon">' +
                  '       <p>'+data+'</p>' +
                  '    </div>' +
                  '</section>';
            return shtml;
        },

        oneLogisMesHtml: function (data,keyWordsCode) {

            // 删除加载的数据
            oContain.find('.js_userLoadingGif').remove();
            oContain.find('.js_platLoadingGif').remove();
            var mesTit = keyWordsCode == 1 ? '已为主人找到所有订单' : '已为主人找到待收货订单';
            var btnText = keyWordsCode == 1 ? '我的订单' : '待收货订单';
            var jumpName = keyWordsCode == 1 ? '' : 'dsh';
            var audioName = keyWordsCode == 1 ? 'audio_order' : 'audio_waitGetOrder'

            var shtml ='';
            var orderType = '';
            var shtmlBox ='';
            for(var i = 0; i < data.length; i++){
                var item = data[i];
                shtmlBox += '<div class="goodsInfoBox HBox ">' +
                    '             <figure>' +
                    '                  <img src="'+HTTP_IMAGE_URL+item.orderItemVoList[0].goodsImage+'" alt="">' +
                    '             </figure>' +
                    '             <aside class="goodsAside Bflex1 VBox">' +
                    '                  <div class="goodsTitMes">' +
                    '                       <h5>'+item.orderItemVoList[0].goodsName+'</h5>' +
                    '                  </div>' +
                    '                  <div class="goodsPriceMes">' +
                    '                       <p>共<span>'+item.quantity+'</span>件，合计￥<span>'+item.paidAmount+'</span></p>' +
                    '                  </div>' +
                    '              </aside>' +
                    '        </div>' ;
            }
            shtml = '<section class="checklogisticGoods marTop_70">' +
                '        <div class="checkLogTit">' +
                '             <p>' +
                '                  <span>'+mesTit+'</span>' +
                '                  <audio class="autoPlayAudio js_autoPlay" preload="auto">' +
                '                       <source class="js_autoPlaySource" src="https://img.sfddj.com/searchAudio/'+audioName+'.mp3" type="audio/mpeg">'+
                '                       <embed class="tts_embed_id" height="0" width="0" src="https://img.sfddj.com/searchAudio/'+audioName+'.mp3">'+
                '                  </audio>'+
                '             </p>' +
                '        </div>' +
                shtmlBox+
                '        <div class="checkLogBotBtn">' +
                '             <p class="js_orderDe checkLogBtn" jumpName="'+jumpName+'">'+btnText+'</p>' +
                '         </div>' +
                '    </section>';

            return shtml;
        },


        platformAnswerHtml: function (data,audioName) {


            // 删除加载的数据
            oContain.find('.js_userLoadingGif').remove();
            oContain.find('.js_platLoadingGif').remove();


            var shtml = '';
            shtml = '<section class="platformAnswerInfo marTop_70">' +
                '        <div class="platformAnswerInfoCon">' +
                '              <p class="posi_re">' +
                '                  <span>'+data.msg+'</span>' +
                '                  <audio class="autoPlayAudio js_autoPlay" style="" preload="auto">' +
                '                           <source class="js_autoPlaySource" src="https://img.sfddj.com/searchAudio/'+audioName+'.mp3" type="audio/mpeg">' +
                '                            <embed class="tts_embed_id" height="0" width="0" src="https://img.sfddj.com/searchAudio/'+audioName+'.mp3">' +
                '                   </audio>'+
                '              </p>' +
                '         </div>' +
                '    </section>';

            return shtml;
        },


        goodsListHtml: function (data) {
            var shtml = '';
            for(var i = 0; i < data.length; i++){
                if(i < 10){
                    var item = data[i];
                    var goodsPrice = item.isTuangou ? item.tuangouPrices : item.salePrice;
                    shtml += '<div class="slide-HScroll swiper-slide">' +
                        '          <a href="/h/goodspay/goodsView/'+item.goodsSn+'" data-growing-title="'+item.name+'">' +
                        '               <figure class="pintuan_radius">'+                                '                    <img class="swiper-lazy" data-src="'+HTTP_IMAGE_URL+item.showImage+smallImgArg300+'" src="/static_v4/image/loadImg.jpg" data-growing-title="'+item.name+'">' +
                        '                </figure>' +
                        '                <aside class="priceArea VBox Bflex1 collageArea pindanArea">' +
                        '                     <div class="Bflex1 priceArea_name">' +
                        '                          <h4>'+item.name +
                        '                          </h4>' +
                        '                     </div>' +
                        '                     <div class="priceArea_price">' +
                        '                          <div class="HBox priceAreaBox">' +
                        '                               <span class="goodsPrice">￥'+goodsPrice+
                        '                                </span>' +
                        '                          </div>' +
                        '                     </div>' +
                        '                </aside>' +
                        '         </a>' +
                        '    </div>';
                }
                else { shtml += '';}


            }
            return shtml;
        },

        goodsListBoxHtml: function (res,value) {
            var $this = this;
            var shtml = '';
            var keyWord = searchObj.userInputVal ? searchObj.userInputVal : value;
            var loadMoreHtml = '';

            //删除加载的信息
            oContain.find('.js_platLoadingGif').remove();
            var checkMoreUrl = res.code == 3 ? '/shop/goods/goodsGroup?groupName=H5首页_当家爆款' : '/shop/goods/tosearchv3?keyword='+ keyWord;

            //如果返回数据的长度没达10个，就不显示“显示更多”按钮
            if(res.data.length >= 10 ){
                loadMoreHtml =
                               '      <a href="'+BASE_URL+ checkMoreUrl +'" class="checkMoreAb posi_re slide-HScroll slide_more swiper-slide posi_re" style="background-color: transparent; height: initial;">' +
                               '          <div class="checkMoreGoodsBtn1">' +
                               '               <img src="/static_v4/image/fakeAI/bg_checkMore_long.png" style="height: 100%; position: absolute; width: 100%; left: 0; top: 0;">'+
                               '          </div>' +
                               '        </a>';
            }

            // console.log('--',res);
            var data = res.data;
            shtml = '<section class="goodsListSwiper js_goodsListSwiper marTop_70">' +
                '         <div class="swiper-container goodsBox_HScroll js_HScroll">' +
                '               <div class="swrap-HScroll swiper-wrapper goodsList js_goodsListScroll">' +
                $this.goodsListHtml(data)                     +
                loadMoreHtml+
                '                </div>' +
                '          </div>' +
                '          <div class="checkHotSaleGoods">' +
                '               <a href="'+BASE_URL+ checkMoreUrl +'" class="checkMoreHot">查看更多</a>' +
                '          </div>'+
                '     </section>';

            return shtml;
        },

        platformLoadingHtml: function () {
            var shtml = '';
            shtml='<section class="platformAnswerInfo js_platLoadingGif posi_re marTop_70">' +
                '        <div class="platformAnswerInfoCon">' +
                '             <p class="icon_big HBox">' +
                '                  <span class="icon_circle icon_circleOne"></span>' +
                '                  <span class="icon_circle icon_circleTwo"></span>' +
                '                  <span class="icon_circle icon_circleThree"></span>' +
                '              </p>' +
                '         </div>' +
                '   </section>';
            return shtml;
        },

        userLoadingHtml: function () {
            var shtml = '';
            shtml='<section class="userSendInfo js_userLoadingGif posi_re marTop_70">' +
                '        <div class="userSendInfoCon">' +
                '             <p class="icon_big HBox">' +
                '                  <span class="icon_circle icon_circleOne"></span>' +
                '                  <span class="icon_circle icon_circleTwo"></span>' +
                '                  <span class="icon_circle icon_circleThree"></span>' +
                '              </p>' +
                '         </div>' +
                '   </section>';
            return shtml;
        },

        couponListDetHtml: function (res) {
            var shtml = '';
            var data = res.data;
            for(var i = 0; i < data.length; i++){
                if(i < 10){
                    var item = data[i];
                    var useLimitHtml = '';
                    var couponClass = item.supplierId > 0 ? "platCoupon" : "";
                    if(item.limitDescribe){
                        useLimitHtml = '   <div class="tip_use" >'+
                            '        <p class="js_subhead">'+item.limitDescribe+'</p>'+
                            '    </div>'
                    }
                    var beginTime = myPub.FormatDateTime(new Date(item.beginDate),'minDay','.');
                    var endTime = myPub.FormatDateTime(new Date(item.endDate),'minDay','.');
                    shtml += '<div class="slide-HScroll swiper-slide">' +
                        '          <a href="'+BASE_URL+'/coupon/couponList">' +
                        '               <div class="coupon '+couponClass+' js_couponCenter" data-isPalt = "'+item.supplierId+'" data-couponId="'+item.id+'">'+
                        '                    <div class="couponBox" >' +
                        '                         <div class="couponInfo HBox">'+
                        '                              <div class="couponInfoLeft HBox BoxCenter">'+
                        '                                   <div class="couponPrice">'+
                        '                                        <em>￥</em>' +
                        '                                        <span>'+item.costPrice+'</span>' +
                        '                                        <p>满'+item.needPrice+'元可用</p>'+
                        '                                   </div>'+
                        '                              </div>'+
                        '                              <div class="couponInfoCenter Bflex1 height_100">'+
                        '                                   <div class="couponUseType">'+
                        '                                        <div class="coupon_tit">'+
                        '                                             <h5 class="singleLine" >'+item.couponName+'</h5>'+
                        useLimitHtml+

                        '                                             <div class="tip_useLimt Bflex1">'+
                        '                                                  <p>'+beginTime+'-'+endTime+'</p>'+
                        '                                             </div>'+
                        '                                        </div>'+
                        '                                   </div>'+
                        '                              </div>'+
                        '                        </div>'+
                        '                   </div>'+
                        '            </div>'+
                        '         </a>' +
                        '    </div>';
                }
                else { shtml += '';}

            }

            return shtml;

        },


        couponListHtml: function (res) {
            var _this = this;
            var data = res;
            var shtml = '';

            var loadMoreHtml = '';

            //删除加载的信息
            oContain.find('.js_platLoadingGif').remove();

            //如果返回数据的长度没达10个，就不显示“显示更多”按钮
            if(res.data.length >= 10 ){
                loadMoreHtml = ' <a href="'+BASE_URL+'/coupon/couponList" class="slide-HScroll slide_more swiper-slide posi_re" style="background-color: transparent; height: initial;">' +
                '                     <div class="">' +
                '                          <img src="/static_v4/image/fakeAI/bg_checkMore_short.png" style="height: 100%; position: absolute; width: 100%; left: 0; top: 0;">'+
                '                     </div>' +
                '                 </a>';
            }

            shtml = '<section class="couponListSwiper js_goodsListSwiper marTop_70">' +
                '         <div class="swiper-container goodsBox_HScroll js_HScroll">' +
                '               <div class="swrap-HScroll swiper-wrapper goodsList js_goodsListScroll">' +
                _this.couponListDetHtml(data)                     +
                loadMoreHtml+
                '                </div>' +
                '          </div>' +
                '          <div class="checkHotSaleGoods">' +
                '               <a class="checkMoreHot" href="'+BASE_URL+'/coupon/couponList">查看我的优惠券</a>' +
                '          </div>'+
                '     </section>';

            return shtml;
        }


    }

})